# Makefile for making GDS/CIF/EGS files up to the suffix of the designated file.
# Normally you only need to supply a C++ source file (e.g. myfile.cc) and
# add the corresponding name of the GDS file in the variable below (e.g.
# myfile.gds).
# Typing 'make' (from appropriate directory in shell) should compile and run the program, 
# producing the GDS file.
# Typing 'make clean' should remove all cif files and all executables and
# backup files.
#
# Xaveer Leijtens 04/03/22
# Yongbo Tang 2012/10/24


# Enter your input <BaseName>.cc
FILE	  = test_sublayout.cc
# You can put more than one file here, separated by a space.

PROG	  = $(basename $(notdir $(FILE)))


# Custom source files folder
CUSTOMOBJDIR = ../../plug_in
# Libmask source files folder
SRCDIR = ../../src

# Compiler
CXX	      = g++
# Linker
LD	      = g++
# Compiler options
CXXFLAGS      = -s -I$(SRCDIR) -I$(CUSTOMOBJDIR)
# Library options
LDFLAGS       = -L$(SRCDIR)
# Libraries
LIBS          = -lMask


all:		objs EXEC

EXEC: $(PROG).o Makefile
		@echo "Generating the execute file..."
		$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(PROG) $< $(LIBS)
		@echo "Executing $(PROG)..."
		./$(PROG)
		@echo "done executing."
		
%.o: %.cc
	$(CXX) -c $(CXXFLAGS) $<
	
objs:
	cd $(SRCDIR); make;
	cd $(CUSTOMOBJDIR); make;
	
.PHONY: clean cleanlib
clean:		
		rm -f $(PROG) *~ *.bak *.o *.cif *.egs *.exe *.stackdump
cleanlib:
		cd $(SRCDIR); make clean;
		cd $(CUSTOMOBJDIR); make clean; 

